<?php
/***
 * 描述：订单商品视图
 * @category		Lib
 * @package			Model			
 * @subpackage	
 * @author			wanght <whtaok@gmail.com>
 * @since			2013-7-30
 * @version			$Id: OrderProductViewModel.class.php 3 2013-10-14 02:49:41Z whtaok@gmail.com $
 */
class OrderProductViewModel extends CommonViewModel{
	//商品价格模型字段
	public $orderDetailViewFields = array(
			'id'				=>'id',
			'prod_name'			=>'prod_name',
			'prod_spec'			=>'prod_spec',
			'prod_spec_unit'	=>'prod_spec_unit',
			'prod_spec_qty'		=>'prod_spec_qty',
			'prod_price_real'	=>'prod_price_real',
			'prod_num'			=>'prod_num',
			'prod_cancel_num'	=>'prod_cancel_num',
			'prod_cancel_stock_status'=>'prod_cancel_stock_status',
		);
	//商品基本表模型字段
	public $orderViewFields = array(
			'shop_id'			=>'shop_id',
			'order_code'		=>'order_code',
			'order_status'		=>'order_status',
			'cust_order_status'	=>'cust_order_status',
			'is_show'			=>'is_show',
			'is_valid'			=>'is_valid',
	);
	//查询商品商品列表
	public function buildProductFields($shop_id){
		
		$orderDetailViewFields = $this->orderDetailViewFields;
		$orderViewFields = $this->orderViewFields;
		$orderViewFields['_on'] = 'OrderLib.order_code = OrderDetail.order_code and OrderLib.shop_id = '.$shop_id;
		$this->viewFields=array(
			'OrderDetail' => $orderDetailViewFields,
			'OrderLib' 	=>$orderViewFields
		);
		return $this;
	}
	
	public function findProdListPage($shop_id,$search,$ordlist){
		$this->buildProductFields($shop_id);
		$totalRows = $this->where($search)->count();
		$rtnData = $this->where($search)->order($ordlist)->listPage($totalRows);
		return $rtnData;
	}
	
}

?>